<!--#include file="./doctype.html"-->
<title><%=editTitle%>网站变量配置-<%=siteTitle%>-后台管理</title>
</head><body>
<div class="wrap">
	<ol class="breadcrumb">
		<li><a href="<%=fileName%>?q=index">列表首页</a></li>
		<li class="active"><a href="javascript:;" class="reload"><%=editTitle%></a></li>
	</ol>
	<div class="alert alert-success">
		<span class="close" data-dismiss="alert">&times;</span>
		<strong>注意：</strong>添加或修改变量时，如果是模板变量的，请使用批量修改，否则在此页面修改ID可能会出错！
	</div>
	<form method="post" action="<%=fileName%>?q=save" class="mb10" role="form">
        <input type="hidden" name="id" value="<%=iid%>">
        <input type="hidden" name="isSystem" value="<%=data(3)%>">
        <div class="form-group fix">
            <input id="configName" name="configName" class="form-control inline w30 check_value" placeholder="变量名称" value="<%=data(0)%>" />
            <label class="inline control-label" for="configName">变量名称(只能为英文开头的英文、数字、下划线)</label>
            <span class="btn btn-default check_name">检测名称</span>
        </div>
        <div class="form-group fix">
            <label class="inline control-label" for="configValue">变量值(支持HTML代码)</label>
            <textarea id="configValue" name="configValue" class="form-control" rows="2" placeholder="变量值"><%=data(1)%></textarea>
        </div>
        <div class="form-group fix">
            <label class="inline control-label" for="configRemark">变量说明</label>
            <textarea id="configRemark" name="configRemark" class="form-control check_value" rows="1" placeholder="变量说明"><%=data(2)%></textarea>
        </div>
		<div class="form-group fix text-center submit_box"></div>
	</form>
    <!--#include file="loadTime.html"-->
</div>
<script>
$(document).ready(function() {
	var check = '<%=data(0)%>' || false,
	checkName = function() {
		$.json({
			url: '<%=fileName%>?q=checkName',
			data: $('form').serializeArray()
		}, function(a) {
			check = (a.error == 0);
		});
	};
	$('.check_value').checkEmpty();
$(this)
	.on('click', '.check_name', function(){
		var val = $('#configName').val();
		if(val == '') {
			return $.message({c: '变量名称不可以为空！'});
		}
		if(val.length < 5) {
			return $.message({c: '变量名称必须5位数以上！'});
		}
		checkName();
	})
	.on('submit', 'form', function(){
		var check1 = $.submitForm('.check_value');
        if(!check1) {
            return check1;
        }
		if(!check) {
			$.message({c: '变量名称没有验证是否存在，不可以提交'});
			return false;
		}
	})
	.on('keyup', '#configName', function(){
		check = false;
		if(this.value.length > 4) {
			checkName();
		}
	})
})
</script>
</body>
</html>